package com.mallcloud.mall.app.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.app.service.AppOrderService;
import com.mallcloud.mall.mall.api.entity.MallOrderModel;
import com.mallcloud.mall.mall.mapper.MallOrderMapper;
import com.mallcloud.mall.mall.service.MallOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 支付订单
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AppOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrderModel> implements AppOrderService {

    @Override
    public void updateTryFail(String orderNo, Integer status, String errMsg) {
        this.update(Wrappers.<MallOrderModel>lambdaUpdate()
                .setSql("VERSION = VERSION + 1")
                .set(MallOrderModel::getExceptions, errMsg)
                .set(MallOrderModel::getStatus, status)
                .eq(MallOrderModel::getOrderNo, orderNo)
        );
    }

}
